Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update the sort logic in the assets grouping #15815

Merged
merged 14 commits into from
May 9, 2024
Merged

Conversation

MikeAlhayek
Copy link
Member

No description provided.

Copy link
Contributor

coderabbitai bot commented Apr 23, 2024

Walkthrough

The recent updates across various scripts and stylesheets primarily focus on code optimization, refactoring, and minor functionality adjustments. Changes include the introduction of new functions for improved class inheritance, the removal of redundant lines and comments, and enhancements in user interaction elements like hover behaviors. These modifications aim to enhance maintainability, readability, and performance of the codebase.

Changes

File Path Change Summary
gulpfile.js Updated asset group path resolution with wildcard support and consistent concatenation order.
.../admin-menu-icon-picker.js, .../admin-menu.js, .../menu.js, .../Taxonomies/wwwroot/Scripts/menu.js Removed lines related to asynchronous execution and data object removal; improved hover interactions.
.../diff.js, .../popper.js, jquery.js, jquery.slim.js Minor changes, mainly removal of empty lines, affecting only formatting.
.../bootstrap.bundle.js, .../bootstrap.js Refactored code structure; introduced _callSuper, modified _isNativeReflectConstruct, and updated utility functions for better class handling.
.../codemirror.js, .../trumbowyg-plugins.js Elimination of unnecessary line breaks and redundant comments.
.../trumbowyg.js Modified handling of the strikethrough command when semantic option is enabled.
.../setup.js Code refactoring: removed redundant code, reordered functions, and refined implementations for clarity and performance.
.../TheAdmin/wwwroot/css/TheAdmin.css Corrected a comment related to CSS imports.
.../TheAdmin/wwwroot/js/TheAdmin.js Removed unnecessary comments and empty lines; updated symbol handling and string conversions in utility functions.

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@MikeAlhayek
Copy link
Member Author

@Piedone why would the validation the building fails? I rebuild the assets.

@Piedone
Copy link
Member

Piedone commented Apr 23, 2024

What's exactly the goal here?

Check out the workflow output with the diff, and/or download the files the workflow built under https://github.com/OrchardCMS/OrchardCore/actions/runs/8808647832?pr=15815 and compare them locally.

@MikeAlhayek
Copy link
Member Author

MikeAlhayek commented Apr 24, 2024

@Piedone the goal is as follow

// The inputPaths can contain either a physical path to a file or a path with a wildcard.
// It's crucial to maintain the order of each file based on its position in the assets.json file.
// When a path contains a wildcard, we need to convert the wildcard to physical paths
// and sort them independently of the previous paths to ensure consistent concatenation.

so if we have

[
  {
    "inputs": [
      "./physical-path1.js",
      "./Assets/js/*.js",
      "./physical-path2.js",
    ]
  }
]

we should append the files in this order

  1. physical-path1.js
  2. all the files sorted from the js folder.
  3. physical-path2.js

@MikeAlhayek
Copy link
Member Author

Check out the workflow output with the diff, and/or download the files the workflow built under https://github.com/OrchardCMS/OrchardCore/actions/runs/8808647832?pr=15815 and compare them locally.

yes but it should not fail here since I rebuild the assets.

@Piedone
Copy link
Member

Piedone commented Apr 24, 2024

Do we have a use case for this among our assets?

What I'd do is download the files and check out the diffs locally. That'll hint at what may go differently.

@hishamco
Copy link
Member

@MikeAlhayek has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 27 minutes and 8 seconds before requesting another review.

Seems a lot of us will wait if there's a rate limiting :)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Out of diff range and nitpick comments (1)
src/OrchardCore.Modules/OrchardCore.Resources/wwwroot/Scripts/codemirror/codemirror.js (1)

Line range hint 1-6: Consider logging exceptions in the empty catch block to avoid suppressing potential errors.

- } catch (e) {}
+ } catch (e) {
+   console.error("Error encountered:", e);
+ }

Copy link
Contributor

This pull request has merge conflicts. Please resolve those before requesting a review.

@MikeAlhayek
Copy link
Member Author

@Piedone I still don't understand why the WF is failing. The order of the concatenated files could have been changed. but the fact that I build the assets should be enough for the WF to work. Are you able to look into it little more please? I think the order of files in this PR is correct and should work.

@Piedone
Copy link
Member

Piedone commented May 2, 2024

Did you download the workflow artifact and check for the changes locally, compared to your files?

@MikeAlhayek
Copy link
Member Author

@Piedone you should be able to see what changed using the diff view here. Looks like spacing changed and order of there the code is added. But, since I recreated all of the resources, it should not detect anything that isn't generated.

This looks strange, it is changing the order of the concatenated files, but it seems that the method definition is changing. I am working if npm install is using a different package version for example "gulp-postcss": "^9.0.1" is in the dependency, when we run npm install its going to install gulp-postcss 9.0.latest and use that.

image

@MikeAlhayek
Copy link
Member Author

Here is another strange one. the new files are generated with a different parameter name for the function than the one in production.

image

@Piedone
Copy link
Member

Piedone commented May 2, 2024

Running npm install, then npm run rebuild for me yields a bunch of changes in this branch too, e.g.:

image

Downloading the artifact from https://github.com/OrchardCMS/OrchardCore/actions/runs/8930280187?pr=15815 yields slightly different changes.

So, it seems that the Gulpfile changes cause the merged files to be flaky/dependent on the platform. I don't know why.

However, I don't think it's worth putting any more time in this. I've spent about a workday sorting this out previously, with the goal of getting it to a stable state, so we can keep updating assets and get a reliable feedback if we've forgotten that. The changes in this PR address a use case that we don't actually have. It'd be nice to have (but still only "nice to have" and low on the list of priorities in my book due to the lack of use cases) if we were to want to maintain this assets pipeline for the foreseeable future, but we want to get rid of it.

@MikeAlhayek
Copy link
Member Author

@Piedone
Copy link
Member

Piedone commented May 2, 2024

I see. I searched and that's the only file where globbing and static paths are mixed. Only globbing is supported, even if multiple wildcard paths are listed (what also happens a few times). So, I suggest expanding that config manually by listing all the files, or converting it to an all-wildcard one.

And if you want to really diligent, then also add a validation here that will fail the pipeline if the two are mixed.

@MikeAlhayek
Copy link
Member Author

Here is the output of that media. The results are what I am expecting.

The logic in main is wrong and the use of .sort() is incorrect in main

[
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/node_modules/blueimp-file-upload/js/jquery.fileupload.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/node_modules/blueimp-file-upload/js/jquery.iframe-transport.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/helpers.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/app.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/fileupload.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/folderComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/font-awesome-thumbnails.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/mediaItemsGridComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/mediaItemsTableComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/pagerComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaApp/sortIndicatorComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaField/attachedMediaField.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaField/mediaFieldThumbsContainer.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaField/mediafield.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/MediaField/mediafieldsAppsArray.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/Shared/uploadComponent.js',
  'C:/Code/OrchardCMS/OrchardCore/src/OrchardCore.Modules/OrchardCore.Media/Assets/js/app/Shared/uploadListComponent.js'
]

@MikeAlhayek
Copy link
Member Author

@Piedone your soon to be favor PR is passing. I am wondering if there was something wrong with my environment. But what I did was to run npm remove gulp-print gulp-debug which generated the updated packages-lock.json file. New files were generated locally and it passed. I am not sure if all I needed was npm cache clean --force

I am just happy that it finally worked and the files sorting is correct.

@MikeAlhayek
Copy link
Member Author

@Piedone you good with this?

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't aware that you're requesting my review here, sorry.

Does gulp watch work for you? For me, it gets stuck on this, never completing and thus never changing the output files:

image

@MikeAlhayek
Copy link
Member Author

@Piedone yes it works for me. Here is what I get as I am saving random file that are being watched

image

@Piedone
Copy link
Member

Piedone commented May 9, 2024

That seems like an in-progress build still. Does the output file change in the end?

@MikeAlhayek
Copy link
Member Author

It does change for me.

image

Copy link
Member

@Piedone Piedone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK then!

@MikeAlhayek MikeAlhayek merged commit 1ba8423 into main May 9, 2024
16 checks passed
@MikeAlhayek MikeAlhayek deleted the ma/fix-gulpfile branch May 9, 2024 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants